package com.test.wog.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.test.wog.bean.Road;
import com.test.wog.dao.RoadDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *关键通道服务层
 * @author linxun@buaa.edu.cn
 * @since 2020-01-18
 * @see Road
 * @see RoadDAO
 */
@Service
public class RoadService {
    @Autowired
    RoadDAO roadDAO;
    public String getAllRoad(){
        List<Road> nodeList = roadDAO.getAllRoad();
        String jsonString = JSONArray.toJSONString(nodeList, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteDateUseDateFormat);
        return jsonString;
    }
    public String getRoadByName(String name){
        List<Road> nodeList = roadDAO.getRoadByName(name);
        String jsonString = JSONArray.toJSONString(nodeList, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteDateUseDateFormat);
        return jsonString;
    }
    public String getRoadByType(String type){
        List<Road> nodeList = roadDAO.getRoadByType(type);
        String jsonString = JSONArray.toJSONString(nodeList, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteDateUseDateFormat);
        return jsonString;
    }
//    public List<Road> getRoadFromAmap(){
//
//    }
}
